package adv2;

import java.util.Objects;

/**
 * @author oldliu
 * @since 1.0
 */
//一个老师代表所有的科目老师
    //通过类别来区分java,还是.net老师===不太合适
public class Teacher implements Comparable<Teacher>{
    private String name;
    private int jiaoling;
    private String type;//不同科目的老师

    public Teacher() {
    }

    public Teacher(String name, int jiaoling, String type) {
        this.name = name;
        this.jiaoling = jiaoling;
        this.type = type;
    }

    public void selfIntroduce(){
        System.out.println("我叫"+name+",教龄是"+jiaoling+"年");
        System.out.println("我是一个"+type+"老师");
    }
    public void giveLession(String className){
        System.out.println(name+"在给"+className+"上课");
    }

    //java老师会使用linux系统
    public void workAtLinux(){
        System.out.println(name+"在使用linux系统 ubuntu 23");
    }
    //ui老师会画广告
    public void paint(){
        System.out.println(name+"在画广告");
    }
    //.net老师会 开发wpf程序
    public void devWpf(){
        System.out.println(name+"在开发wpf图形程序");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Teacher teacher = (Teacher) o;
        //name.equals(teacher.name);//???
        return Objects.equals(name, teacher.name) && Objects.equals(type, teacher.type);
    }
    @Override
    public int hashCode() {
        return Objects.hash(name, type);
    }
    @Override
    public String toString() {
        return "Teacher{" +
                "name='" + name + '\'' +
                ", jiaoling=" + jiaoling +
                ", type='" + type + '\'' +
                '}';
    }

    //>0,this>o
    //==0:this=o
    //<0 this<o
    @Override
    public int compareTo(Teacher o) {
        return this.jiaoling-o.jiaoling;
//        if(this.name==null)
//            return -1;
//        if(o.name==null)
//            return 1;
//        return this.name.compareTo(o.name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getJiaoling() {
        return jiaoling;
    }

    public void setJiaoling(int jiaoling) {
        this.jiaoling = jiaoling;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
